
import { _decorator, Component, Vec2, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Player')
export class Player extends Component {

    @property
    speed: number = 5;

    private _moveDirection: Vec2 | undefined;

    public move(direction: Vec2) {
        this._moveDirection = direction;
    }

    update(deltaTime: number) {
        if (!this._moveDirection) return;
        this.node.translate(v3(this._moveDirection.x * this.speed * deltaTime, this._moveDirection.y * this.speed * deltaTime, 0));
    }
}
